package com.dragon.modules.yuegou.service.wallet;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dragon.common.web.PageRequest;
import com.dragon.modules.yuegou.entity.wallet.MemberTradeEntity;
import com.dragon.modules.yuegou.enums.CurrencyType;
import com.dragon.modules.yuegou.enums.wallet.MemberTradeType;
import com.dragon.modules.yuegou.model.busd.District;
import com.dragon.modules.yuegou.model.company.Company;
import com.dragon.modules.yuegou.model.order.OrderJingdongSku;
import com.dragon.modules.yuegou.model.system.Document;
import com.dragon.modules.yuegou.model.wallet.EarlyMemberCard;
import com.dragon.modules.yuegou.model.wallet.MemberCard;
import com.dragon.modules.yuegou.model.wallet.MemberTrade;
import com.dragon.modules.yuegou.query.wallet.TradeQuery;
import com.dragon.modules.yuegou.request.CardConsumeRecordRequest;
import com.dragon.modules.yuegou.request.CardYueLiftRecordRequest;
import com.dragon.modules.yuegou.request.CardYueLiftRefundRequest;
import com.dragon.modules.yuegou.response.CardConsumeRecordResponse;
import com.dragon.modules.yuegou.response.CardYueLiftRecordResponse;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
 * 会员交易（在会员视角的交易流水） 服务接口
 *
 * @author pbuilder generated
 * @date 2019-07-10 17:57:17
 * @version 2.0
 */
public interface MemberTradeService extends IService<MemberTradeEntity> {

	/**
	 * 悦卡消费记录
	 * */
	IPage<MemberTrade> cardPayRecords(PageRequest page, String memberId);

	/**
	 * 悦币消费记录
	 * */
	IPage<MemberTrade> coinPayRecords(PageRequest page, String memberId);

	/**
	 *交易记录
	 * */
	IPage<MemberTrade> transactionList(PageRequest page, String memberId,String date,String busdId);

	/**
     * 集团版查询交易明细列表
     * @param page
     * @param query
     * @return
     */
    IPage<MemberTrade> searchTradeList(PageRequest page, TradeQuery query);

	/**
	 * 导出交易明细
	 * @param query
	 * @return
	 */
	Document exportDetail(TradeQuery query);

	/**
	 * 保存交易记录
	 * @param memberCard
	 * @param orderNo
	 * @param amount
	 */
	void saveTrade(String memberId, String merchantId, MemberCard memberCard, String orderNo, BigDecimal amount, CurrencyType currencyType, MemberTradeType tradeType, String remarks);

	/**
	 * 保存交易记录
	 * @param memberCard
	 * @param orderNo
	 * @param amount
	 */
	void saveTrade(String memberId, String merchantId, MemberCard memberCard, String orderNo, BigDecimal amount, CurrencyType currencyType, MemberTradeType tradeType,String remarks,String thirdMchId);


	/**
	 * 分页查询会员悦币记录
	 * */
	IPage<MemberTrade> search(PageRequest page, MemberTrade query);

	List<MemberTrade> search1( MemberTrade query);
	
	 Map<String,BigDecimal> getIncome(String memberId,String date);

	/**
	 * 统计企业发票
	 * @param district
	 * @param beginTime
	 * @param endTime
	 * @return
	 */
    List<Company> companyInvoice(District district, LocalDateTime beginTime, LocalDateTime endTime);

	Document exportRecharge(MemberTrade query);

	/**
	 * 悦卡使用记录
	 * @param page
	 * @param request
	 * @return
	 */
    IPage<CardConsumeRecordResponse> searchConsumeRecord(PageRequest page, CardConsumeRecordRequest request);

	/**
	 * 导出悦卡使用记录
	 * @param request
	 * @return
	 */
    Document exportConsumeRecord(CardConsumeRecordRequest request);

	/**
	 * 根据订单号查询交易记录
	 * @param orderNo
	 * @return
	 */
	List<MemberTrade> getByOrderNo(String orderNo);

    IPage<CardYueLiftRecordResponse> searchYueLiftRecord(PageRequest page, CardYueLiftRecordRequest request);

	Document exportYueLiftRecord(CardYueLiftRecordRequest request);

	/**
	 * 保存大汉悦生活支付记录
	 * @param busdId
	 * @param earlyMemberCard
	 */
    void saveTrade(String busdId, EarlyMemberCard earlyMemberCard,MemberTradeType memberTradeType);


	/**
	 * 保存大汉悦生活退卡记录
	 * @param busdId
	 * @param earlyMemberCard
	 */
	void saveRefundTrade(String busdId,MemberCard memberCard, EarlyMemberCard earlyMemberCard);


	List<OrderJingdongSku> yueLiftRecordDetail(String orderNo);
	
	void yueLiftRefund(CardYueLiftRefundRequest request);
}